<template>
    <h3>注册</h3>
    <div>
        <table>
            <tr>
                <td>用户名：</td>
                <td><input type="text" v-model="UName"></td>
            </tr>
            <tr>
                <td>密码：</td>
                <td><input type="password" v-model="UPwd"></td>
            </tr>
            <tr>
                <td><button @click="Register">注册</button></td>
            </tr>
        </table>
    </div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import axios from 'axios'
const UName = ref("")
const UPwd = ref("")
const Register = () => {

    if (!UName.value) {
        alert("用户名不能为空")
    }
    axios.post('http://localhost:64090/api/Users/Register', {
        UName: UName.value,
        UPwd: UPwd.value

    })
        .then(res => {
            console.log(res);
            if (res.data > 0) {
                alert("注册成功")
                location.href = './Login'
            }
            else {
                alert("注册失败")
                return;
            }
        })
        .catch(eorror => {
            alert(eorror)
        })

}
</script>